package control;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Spinner;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

// 选择器
public class SpinnerDemo extends Application {
	private Pane root = new Pane();
	private Spinner<Integer> spinner1;
	private Spinner<String> spinner2;
	
	public static void main(String[] args) {
		launch(args);
	}
	
	@Override
	public void start(Stage stage) {
		
		// 最小值,最大值,初始值,变化值
		spinner1 = new Spinner<Integer>(0, 10, 2, 2);	
		
		ObservableList<String> list = FXCollections.observableArrayList();
		list.addAll("A", "B", "C", "D");
		spinner2 = new Spinner<String>(list);
		spinner2.getStyleClass().add(Spinner.STYLE_CLASS_ARROWS_ON_RIGHT_HORIZONTAL);	// 选择箭头水平且位于右边
		spinner2.setLayoutY(50);
		root.getChildren().addAll(spinner1, spinner2);
		
		Scene scene = new Scene(root, 300, 250);
		stage.setScene(scene);
		stage.show();
	}
}
